package com.mszlu.blog.handler;


import com.mszlu.blog.vo.Result;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import org.springframework.web.bind.annotation.ResponseBody;

//对加了@Controller注解的方法进行拦截AOP的实现
@ControllerAdvice
public class AllExceptionHandler {
    //进行异常处理，处理Exception.class的异常
    @ExceptionHandler(Exception.class)
    @ResponseBody //返回的是json数据 不加返回的是页面
  public Result doException(Exception ex){
      ex.printStackTrace();
      return Result.fail(-999,"系统异常");
  }
}
